package com.tsmti.task.listener;

import com.tsmti.core.util.SpringContextUtils;
import com.tsmti.task.service.ScheduleJobService;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * @Package：com.tsmti.task.listener
 * @Class：ScheduleJobInitListener
 * @Description： TODO
 * @Author：zcw
 * @Date：Created in 2018/5/15 22:55
 * @Company:
 * @Version：
 * @Modified By:
 */
public class ScheduleJobInitListener implements ApplicationListener<ContextRefreshedEvent> {

    protected ScheduleJobService scheduleJobService = SpringContextUtils.getApplicationContext()
            .getBean(ScheduleJobService.class);

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        try {
            scheduleJobService.initSchedule();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
